package com.ehsy.service;

import com.dtflys.forest.annotation.*;
import com.dtflys.forest.http.Lazy;
import com.ehsy.common.ResponseVo;
import com.ehsy.model.MyHeaders;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @author YanZhen_Li
 * @version 1.0
 * @title HeadersService
 * @description
 * @create 2024/6/17 16:22
 */
@Component
@Address(host = "127.0.0.1", port = "8080")
public interface HeadersService {
    /**
     * 配置多个请求头
     */
    @Request(
            url = "/test/request/json/body",
            headers = {
                    "Accept-Charset: utf-8",
                    "Content-Type: text/plain",
                    "name: Jerry_Li"
            }
    )
    ResponseVo<Object> test01();

    /**
     * 从参数中获取请求头
     */
    @Request(
            url = "/test/request/json/body",
            headers = {
                    "username: ${name}",
            }
    )
    ResponseVo<Object> test02(@Var("name") String name);

    /**
     * 添加单个请求头
     */
    @Request("/test/request/json/body")
    ResponseVo<Object> test03(@Header("myname") String name);

    /**
     * 批量添加请求头
     */
    @Request("/test/request/json/body")
    ResponseVo<Object> test04(@Header Map<String, Object> map);

    /**
     * 根据对象批量添加请求头
     */
    @Request("/test/request/json/body")
    ResponseVo<Object> test05(@Header MyHeaders headers);

    /**
     * 模拟添加token
     */
    @Request("/test/request/json/body")
    ResponseVo<Map<String, Object>> test06(@Query("name1") String a,
                                           @Query("name2") String b,
                                           @Header("token") Lazy<String> token);

    /**
     * 模拟加密测试
     */
    @Request("/test/request/json/body")
    ResponseVo<Map<String, Object>> test07(@Query("name1") String a,@Query("name2") String jerry,@Query("encryption") Lazy<String> encryption);
}
